/*
 * Ext GWT - Ext for GWT
 * Copyright(c) 2007-2009, Ext JS, LLC.
 * licensing@extjs.com
 * 
 * http://extjs.com/license
 */
package com.hy.mydesktop.client.mvc.logindialog;


import java.util.ArrayList;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.logging.Level;

import org.dom4j.DocumentException;


import com.allen_sauer.gwt.log.client.Log;
import com.extjs.gxt.desktop.client.Desktop;
import com.extjs.gxt.ui.client.Registry;
import com.extjs.gxt.ui.client.Style.LayoutRegion;
import com.extjs.gxt.ui.client.core.FastMap;
import com.extjs.gxt.ui.client.data.BaseModel;
import com.extjs.gxt.ui.client.data.BaseModelData;
import com.extjs.gxt.ui.client.data.ModelData;
import com.extjs.gxt.ui.client.event.BaseEvent;
import com.extjs.gxt.ui.client.event.ButtonEvent;
import com.extjs.gxt.ui.client.event.ComponentEvent;
import com.extjs.gxt.ui.client.event.EventType;
import com.extjs.gxt.ui.client.event.Events;
import com.extjs.gxt.ui.client.event.Listener;
import com.extjs.gxt.ui.client.event.SelectionListener;
import com.extjs.gxt.ui.client.event.WindowEvent;
import com.extjs.gxt.ui.client.mvc.AppEvent;
import com.extjs.gxt.ui.client.mvc.Controller;
import com.extjs.gxt.ui.client.mvc.Dispatcher;
import com.extjs.gxt.ui.client.mvc.View;
import com.extjs.gxt.ui.client.util.Margins;
import com.extjs.gxt.ui.client.widget.Component;
import com.extjs.gxt.ui.client.widget.ContentPanel;
import com.extjs.gxt.ui.client.widget.HtmlContainer;
import com.extjs.gxt.ui.client.widget.LayoutContainer;
import com.extjs.gxt.ui.client.widget.MessageBox;
import com.extjs.gxt.ui.client.widget.Viewport;
import com.extjs.gxt.ui.client.widget.button.Button;
import com.extjs.gxt.ui.client.widget.form.Field;
import com.extjs.gxt.ui.client.widget.form.FormPanel;
import com.extjs.gxt.ui.client.widget.form.TextField;
import com.extjs.gxt.ui.client.widget.form.Validator;
import com.extjs.gxt.ui.client.widget.grid.Grid;
import com.extjs.gxt.ui.client.widget.layout.AccordionLayout;
import com.extjs.gxt.ui.client.widget.layout.BorderLayout;
import com.extjs.gxt.ui.client.widget.layout.BorderLayoutData;
import com.extjs.gxt.ui.client.widget.layout.FitLayout;
import com.google.gwt.core.client.GWT;
import com.google.gwt.dev.jjs.impl.GwtAstBuilder;
import com.google.gwt.user.client.Command;
import com.google.gwt.user.client.Timer;
import com.google.gwt.user.client.Window;
import com.google.gwt.user.client.rpc.AsyncCallback;
import com.google.gwt.user.client.ui.HasWidgets;
import com.google.gwt.user.client.ui.RootPanel;
import com.google.gwt.user.client.ui.Widget;
import com.hy.mydesktop.client.MyDesktop;
import com.hy.mydesktop.client.component.event.AppEvents;
import com.hy.mydesktop.client.component.mvc.event.EventStructureMetaModel;
import com.hy.mydesktop.client.component.mvc.factory.GxtComponentControlerFactory;
import com.hy.mydesktop.client.component.type.ComponentControllerEnum;
import com.hy.mydesktop.client.component.type.ComponentTypeEnum;
import com.hy.mydesktop.client.mvc.base.BaseDisplay;
import com.hy.mydesktop.client.mvc.base.Presenter;
import com.hy.mydesktop.client.mvc.constant.MvcConstants;
import com.hy.mydesktop.client.mvc.window.WindowController;
import com.hy.mydesktop.client.rpc.ServiceInvoker;
import com.hy.mydesktop.client.rpc.ServiceInvokerAsync;
import com.hy.mydesktop.server.service.InitGxtSystemDatas;
import com.hy.mydesktop.shared.business.DeaktopInitService;
import com.hy.mydesktop.shared.business.DepartmentServices;
import com.hy.mydesktop.shared.business.DesktopService;
import com.hy.mydesktop.shared.persistence.domain.gxt.GxtAppEventType;
import com.hy.mydesktop.shared.persistence.domain.gxt.GxtComponentControllerMetaModel;
import com.hy.mydesktop.shared.persistence.domain.gxt.GxtComponentControllerMetaNodeModel;
import com.hy.mydesktop.shared.persistence.domain.gxt.GxtComponentMetaModel;
import com.hy.mydesktop.shared.persistence.domain.gxt.GxtComponentMetaNodeModel;
import com.hy.mydesktop.shared.persistence.domain.gxt.constant.LibConstants;
import com.hy.mydesktop.shared.persistence.domain.gxt.constant.MetaDataConstants;
import com.hy.mydesktop.shared.rpc.meta.GxtToSeamServiceParameter;
import com.hy.mydesktop.shared.rpc.meta.GxtToSeamServiceResult;
import com.hy.mydesktop.shared.util.log.GwtDebugStrUtil;
import com.hy.mydesktop.shared.util.log.GwtLogHelper;
import com.hy.mydesktop.shared.util.log.MyLoggerUtil;
/**
 * 
 * 
 * <ul>
 * <li>开发作者：花宏宇</li>
 * <li>设计日期：2011-9-13；时间：上午11:17:24</li>
 * <li>类型名称：LoginPresenter</li>
 * <li>设计目的：</li>
 * </ul>
 * <ul>
 * <b>修订编号：</b>
 * <li>修订日期：</li>
 * <li>修订作者：</li>
 * <li>修订原因：</li>
 * <li>修订内容：</li>
 * </ul>
 */
public class LoginPresenter extends View implements Presenter{

    final ServiceInvokerAsync serviceInvoker = Registry.get(MyDesktop.SERVICEINVOKER);
  public Display display = null;;

  /*public LoginPresenter(Controller controller) {
    super(controller);
  }*/
  
  public LoginPresenter(Controller controller,Display display) {
	    super(controller);
	    this.display = display;
		MyLoggerUtil.printDebug(this.getClass(), "创建 "+this.getClass().getName());

	    bind();
  }


  public interface Display extends BaseDisplay{
		public Button getLoginButton() ;
		public TextField<String> getUserNameTextField() ;
		public TextField<String> getPasswordTextField() ;
		public LoginDialog getLoginDialog() ;
		public void show();


	}
  
  @Override
	public void go(HasWidgets container) {
		// TODO Auto-generated method stub

	}

	@Override
	public void bind() {
		//validateLogin();
		//监听用户登录提交
	    display.getLoginButton().addSelectionListener(new SelectionListener<ButtonEvent>() {
	      public void componentSelected(ButtonEvent ce) {
	    	  
	    	  onSubmit();
	    	  //Log.debug("loginDialog.loginButton 触发 AppEvents.DESKTOP_UER_LOGIN_VALIDATE 事件");
	    	  MyLoggerUtil.printDebug(this.getClass(), "loginDialog.loginButton 触发 AppEvents.DESKTOP_UER_LOGIN_VALIDATE 事件");
	    	  //窗口隐藏
		        //LoginDialog.this.hide();
		        //触发用户登录事件事件
	    	  AppEvent appEvent = new AppEvent(AppEvents.DESKTOP_UER_LOGIN_VALIDATE);
	    	  appEvent.setData("eventName", "AppEvents.DESKTOP_UER_LOGIN_VALIDATE");
		        Dispatcher.forwardEvent(appEvent);
	      }
	    });
	   // Button loginButton = display.getLoginButton();
	   // List<Listener<? extends BaseEvent>> listeners = loginButton.getListeners(Events.Select);
	    //listeners.
	}
	
	private Boolean validateLogin() {
		
		display.getUserNameTextField().setValidator(new Validator() {
			
			@Override
			public String validate(Field<?> field, String value) {
				String str = (String)field.getValue();
				if (str==null||str.length()<3) {
					return "您输入的内容太短！";
				}
				return null;
			}
		});
		display.getUserNameTextField().setValidateOnBlur(true);

		return true;
	}
	
	protected void onSubmit() {
	    //status.show();
	    //getButtonBar().disable();
	    Timer t = new Timer() {

	      @Override
	      public void run() {
	    	  //窗口隐藏
	        //LoginDialog.this.hide();
	        //触发用户登录事件事件
	       // Dispatcher.forwardEvent(AppEvents.DESKTOP_UER_LOGIN_VALIDATE);
	      }

	    };
	    t.schedule(2000);
	  }
  /*
  protected void initialize() {
	*//**
	 *  LoginDialog dialog = new LoginDialog();   
	 *  通过Rpc，提交dialog获得的用户名密码
	 *  获得返回值
	 *  如果是ture，
	 *  如果是false，重定向到LoginDialog
	 *//*
	  dialog= new LoginDialog();   
	  dialog.setClosable(false);  
	final GxtToSeamServiceParameter gxtToSeamServiceParameter = new GxtToSeamServiceParameter();
	gxtToSeamServiceParameter.setServiceComponentName("com.test.server.business.PersonService");
	gxtToSeamServiceParameter.setServiceMethodName("loadGxtComponentMetaModel");
	ModelData[] methodArguments2 = new BaseModelData[1];
	methodArguments2[0] = new BaseModel();
	gxtToSeamServiceParameter.setMethodArguments(methodArguments2 );   
    dialog.show();
  }
  
  *//**
   * 模拟从后台传入的元模型信息（关于快捷方式的）
   *//*
  private GxtComponentMetaModel getDesktopMetaModel() {
		Map<String, Object> map1=new HashMap<String, Object>();
		map1.put("component_model_type", ComponentTypeEnum.DESKTOP_MODEL);
		GxtComponentMetaNodeModel node1=new GxtComponentMetaNodeModel(map1, 1, 10);
		
		Map<String, Object> map2=new HashMap<String, Object>();
		map2.put("component_model_type", ComponentTypeEnum.SHORTCUT_MODEL);
		//TODO map2.put("appEventType", AppEvents.DESKTOP_SHORTCUT_ONCLICK_INIT);
		map2.put("appEventType", AppEvents.DESKTOP_SHORTCUT_ONCLICK_INIT);
			Map<String,Object> codes2 = new HashMap<String, Object>();
			//添加需要监听的事件类型，及附加参数和数据
			*//**
			 * 00_01_02为特征码
			 * 
			 *//*
			codes2.put("0003", "00_01_02");
			//codes1.add("0002");
		map2.put("registereventtypes", codes2);
		map2.put("text", "createWindow-----111LoginView----AppEvents.DESKTOP_INIT_FOR_LOGGED_IN_USER");	
		GxtComponentMetaNodeModel node2=new GxtComponentMetaNodeModel(map2, 2, 3);
		
		Map<String, Object> map3=new HashMap<String, Object>();
		map3.put("component_model_type", ComponentTypeEnum.SHORTCUT_MODEL);
		map3.put("text", "222LoginView----AppEvents.DESKTOP_INIT_FOR_LOGGED_IN_USER");			
			Map<String,Object> codes3 = new HashMap<String, Object>();
			codes3.put("0003", "00_01_02");
			//codes1.add("0002");
			map3.put("registereventtypes", codes3);
		GxtComponentMetaNodeModel node3=new GxtComponentMetaNodeModel(map3, 4, 5);
		
		Map<String, Object> map4=new HashMap<String, Object>();
		map4.put("component_model_type", ComponentTypeEnum.DESKTOP_MENUITEM_MODEL);
		map4.put("text", "001LoginView----AppEvents.DESKTOP_INIT_FOR_LOGGED_IN_USER");			
			Map<String,Object> codes4 = new HashMap<String, Object>();
			codes4.put("0003", "00_01_02");
			//codes1.add("0002");
			map4.put("registereventtypes", codes4);
		GxtComponentMetaNodeModel node4=new GxtComponentMetaNodeModel(map4, 6, 7);
		
		Map<String, Object> map5=new HashMap<String, Object>();
		map5.put("component_model_type", ComponentTypeEnum.DESKTOP_MENUITEM_MODEL);
		map5.put("text", "002LoginView----AppEvents.DESKTOP_INIT_FOR_LOGGED_IN_USER");			
			Map<String,Object> codes5 = new HashMap<String, Object>();
			codes5.put("0003", "00_01_02");
			//codes1.add("0002");
			map5.put("registereventtypes", codes5);
		GxtComponentMetaNodeModel node5=new GxtComponentMetaNodeModel(map5, 8, 9);
		
		List<GxtComponentMetaNodeModel> list = new ArrayList<GxtComponentMetaNodeModel>();
		list.add(node1);
		list.add(node2);
		list.add(node3);
		list.add(node4);
		list.add(node5);
		GxtComponentMetaModel gxtComponentMetaModel = new GxtComponentMetaModel();
		gxtComponentMetaModel.setList(list);
		
		return gxtComponentMetaModel;
		
	}
	
  
  
  *//**
   * Desktop的桌面的元模型信息
   *//*
  private Controller createDynamicDesktopController() {
		Map<String , Object> desktopController=new HashMap<String, Object>();
		desktopController.put("component_controller_model_type", ComponentControllerEnum.DESKTOP_CONTROLLOR_MODEL);
		List<String> codes1 = new ArrayList<String>();
		codes1.add("0003");
		codes1.add("0002");
		codes1.add("0005");
		desktopController.put("registereventtypes", codes1);
		desktopController.put("id", "desktopController");
		GxtComponentMetaNodeModel node=new GxtComponentMetaNodeModel(desktopController,1,14);
		
		Map<String , Object> shortcutController=new HashMap<String, Object>();
		shortcutController.put("component_controller_model_type", ComponentControllerEnum.SHORTCUT_CONTROLLER_MODEL);
		List<String> codes2 = new ArrayList<String>();
		codes2.add("0003");
		codes2.add("0002");
		codes2.add("0005");
		shortcutController.put("registereventtypes", codes2);
		shortcutController.put("id", "shortcutController01");
		shortcutController.put("viewdata", "shortcut_viewData_init_01");		
		GxtComponentMetaNodeModel node2=new GxtComponentMetaNodeModel(shortcutController,2,3);
		
		Map<String , Object> shortcutController2=new HashMap<String, Object>();
		shortcutController2.put("component_controller_model_type", ComponentControllerEnum.SHORTCUT_CONTROLLER_MODEL);
		List<String> codes22 = new ArrayList<String>();
		codes22.add("0003");
		codes22.add("0002");
		codes22.add("0005");
		shortcutController2.put("registereventtypes", codes22);
		shortcutController2.put("id", "shortcutController03");
		shortcutController2.put("viewdata", "shortcut_viewData_init_03");		
		GxtComponentMetaNodeModel node22=new GxtComponentMetaNodeModel(shortcutController2,4,5);
		
		Map<String , Object> desktopMeunItemController=new HashMap<String, Object>();
		desktopMeunItemController.put("component_controller_model_type", ComponentControllerEnum.DESKTOP_MENUITEM_CONTROLLER_MODEL);
		List<String> codes3 = new ArrayList<String>();
		codes3.add("0003");
		codes3.add("0002");
		codes3.add("0005");
		desktopMeunItemController.put("registereventtypes", codes3);
		desktopMeunItemController.put("id", "desktopMeunItemController01");
		desktopMeunItemController.put("viewdata", "desktopmenuitem_viewData_init_01");		
		GxtComponentMetaNodeModel node3=new GxtComponentMetaNodeModel(desktopMeunItemController,6,7);
		
		
		Map<String , Object> desktopMeunItemController2=new HashMap<String, Object>();
		desktopMeunItemController2.put("component_controller_model_type", ComponentControllerEnum.DESKTOP_MENUITEM_CONTROLLER_MODEL);
		List<String> codes32 = new ArrayList<String>();
		codes32.add("0003");
		codes32.add("0002");
		codes32.add("0005");
		desktopMeunItemController2.put("registereventtypes", codes32);
		desktopMeunItemController2.put("id", "desktopMeunItemController02");
		desktopMeunItemController2.put("viewdata", "desktopmenuitem_viewData_init_02");		
		GxtComponentMetaNodeModel node32=new GxtComponentMetaNodeModel(desktopMeunItemController2,8,9);
		
		Map<String , Object> desktopStartMenuController=new HashMap<String, Object>();
		desktopStartMenuController.put("component_controller_model_type", ComponentControllerEnum.DESKTOP_STARTMENU_CONTROLLER_MODEL);
		List<String> codes4 = new ArrayList<String>();
		codes4.add("0003");
		codes4.add("0002");
		codes4.add("0005");
		desktopStartMenuController.put("registereventtypes", codes4);
		desktopStartMenuController.put("id", "desktopStartMenuController01");
		desktopStartMenuController.put("viewdata", "desktopStartMenu_viewData_init_01");		
		GxtComponentMetaNodeModel node4=new GxtComponentMetaNodeModel(desktopStartMenuController,10,11);
		
		Map<String , Object> desktopStartMenuController2=new HashMap<String, Object>();
		desktopStartMenuController2.put("component_controller_model_type", ComponentControllerEnum.DESKTOP_STARTMENU_CONTROLLER_MODEL);
		List<String> codes42 = new ArrayList<String>();
		codes42.add("0003");
		codes42.add("0002");
		codes42.add("0005");
		desktopStartMenuController2.put("registereventtypes", codes42);
		desktopStartMenuController2.put("id", "desktopStartMenuController02");
		desktopStartMenuController2.put("viewdata", "desktopStartMenu_viewData_init_02");		
		GxtComponentMetaNodeModel node42=new GxtComponentMetaNodeModel(desktopStartMenuController2,12,13);

		
		List<GxtComponentMetaNodeModel> list=new ArrayList<GxtComponentMetaNodeModel>();
		list.add(node);
		list.add(node2);
		list.add(node22);
		list.add(node3);		
		list.add(node32);		
		list.add(node4);		
		list.add(node42);		
		GxtComponentMetaModel gxtComponentMetaModel=new GxtComponentMetaModel(list);
		return GxtComponentControlerFactory.createGxtComponentController(gxtComponentMetaModel);
		
	}
	
  *//**
	 * 动态创建树形控制器----窗口相关
	 *//*
	private Controller createDynamicController() {
		Map<String , Object> windowController=new HashMap<String, Object>();
		windowController.put("component_controller_model_type", ComponentControllerEnum.WINDOW_CONTROLLER_MODEL);
		List<String> codes1 = new ArrayList<String>();
		codes1.add("0101");
		codes1.add("0301");		
		codes1.add("0003");
		codes1.add("0201");
		//codes1.add("0005");
		codes1.add("0007");
		codes1.add("0008");
		
		windowController.put("id", "windowController");
		windowController.put("registereventtypes", codes1);
		windowController.put("viewdata", "window_viewData_init_01");		
		GxtComponentMetaNodeModel node=new GxtComponentMetaNodeModel(windowController,1,12);
		
		Map<String , Object> contentPanelController=new HashMap<String, Object>();
		contentPanelController.put("component_controller_model_type", ComponentControllerEnum.CONTENTPANEL_CONTROLLER_MODEL);
		List<String> codes2 = new ArrayList<String>();
		codes2.add("0201");
		codes2.add("0301");
		codes2.add("0101");
		codes2.add("0007");
		codes2.add("0008");
		contentPanelController.put("registereventtypes", codes2);				
		contentPanelController.put("id", "contentPanelController");				
		contentPanelController.put("viewdata", "contentPanel_viewData_init_01");		
		GxtComponentMetaNodeModel node2=new GxtComponentMetaNodeModel(contentPanelController,2,11);
		
		Map<String , Object> menuBarController=new HashMap<String, Object>();
		menuBarController.put("component_controller_model_type", ComponentControllerEnum.MENUBAR_CONTROLLER_MODEL);
		List<String> codes3 = new ArrayList<String>();
		codes3.add("0201");
		codes3.add("0301");
		codes3.add("0101");
		codes3.add("0007");
		codes3.add("0008");
		menuBarController.put("registereventtypes", codes3);
		menuBarController.put("id", "menuBarController");
		menuBarController.put("viewdata", "menuBar_viewData_init_01");		
		GxtComponentMetaNodeModel node3=new GxtComponentMetaNodeModel(menuBarController,3,4);
		
		Map<String , Object> toolBarController=new HashMap<String, Object>();
		toolBarController.put("component_controller_model_type", ComponentControllerEnum.TOOLBAR_CONTROLLER_MODEL);
		List<String> codes4 = new ArrayList<String>();
		codes4.add("0201");
		codes4.add("0301");
		codes4.add("0101");
		codes4.add("0007");
		codes4.add("0008");
		toolBarController.put("registereventtypes", codes4);
		toolBarController.put("id", "toolBarController");
		toolBarController.put("viewdata", "toolBar_viewData_init_01");		
		GxtComponentMetaNodeModel node4=new GxtComponentMetaNodeModel(toolBarController,5,6);
		
		Map<String , Object> formPanelController=new HashMap<String, Object>();
		formPanelController.put("component_controller_model_type", ComponentControllerEnum.FORMSET_MODULE_CONTROLLER_MODEL);
		List<String> codes5 = new ArrayList<String>();
		codes5.add("0201");
		codes5.add("0301");
		codes5.add("0101");
		codes5.add("0007");
		codes5.add("0008");
		formPanelController.put("registereventtypes", codes5);
		formPanelController.put("id", "formPanelController");
		formPanelController.put("controllerdata", "formPanel_controllerdata_init_01");		
		formPanelController.put("viewdata", "formPanel_viewData_init_01");		
		GxtComponentMetaNodeModel node5=new GxtComponentMetaNodeModel(formPanelController,7,10);
		
		Map<String , Object> textFieldController=new HashMap<String, Object>();
//		textFieldController.put("component_controller_model_type", ComponentControllerEnum.GRID_MODEL);
		textFieldController.put("component_controller_model_type", ComponentControllerEnum.GRID_CONTROLLER_MODEL);
		List<String> codes6 = new ArrayList<String>();
		codes6.add("0301"); 
		codes6.add("0201"); 
		codes6.add("0101");
		codes6.add("0007");
		codes6.add("0008");
		textFieldController.put("registereventtypes", codes6);
		textFieldController.put("id", "textFieldController");
		textFieldController.put("viewdata", "textField_viewData_init_01");		
		GxtComponentMetaNodeModel node6=new GxtComponentMetaNodeModel(textFieldController,8,9);
		
		Map<String , Object> textFieldController=new HashMap<String, Object>();
		textFieldController.put("component_controller_model_type", ComponentControllerEnum.TEXTFIELD_CONTROLLER_MODEL);
		List<String> codes6 = new ArrayList<String>();
		codes6.add("0301"); 
		codes6.add("0201"); 
		codes6.add("0101");
		codes6.add("0007");
		codes6.add("0008");
		textFieldController.put("registereventtypes", codes6);
		textFieldController.put("id", "textFieldController");
		textFieldController.put("viewdata", "textField_viewData_init_01");		
		GxtComponentMetaNodeModel node6=new GxtComponentMetaNodeModel(textFieldController,8,9);
		
		Map<String , Object> comboBoxController=new HashMap<String, Object>();
		comboBoxController.put("component_controller_model_type", ComponentControllerEnum.COMBOBOX_CONTROLLER_MODEL);
		List<String> codes6 = new ArrayList<String>();
		codes6.add("0301"); 
		codes6.add("0201"); 
		codes6.add("0101");
		codes6.add("0007");
		codes6.add("0008");
		comboBoxController.put("registereventtypes", codes6);
		comboBoxController.put("id", "textFieldController");
		comboBoxController.put("viewdata", "textField_viewData_init_01");		
		GxtComponentMetaNodeModel node6=new GxtComponentMetaNodeModel(comboBoxController,8,9);
		
		Map<String , Object> dateFieldController=new HashMap<String, Object>();
		dateFieldController.put("component_controller_model_type", ComponentControllerEnum.DATEFIELD_CONTROLLER_MODEL);
		List<String> codes6 = new ArrayList<String>();
		codes6.add("0301"); 
		codes6.add("0201"); 
		codes6.add("0101");
		codes6.add("0007");
		codes6.add("0008");
		dateFieldController.put("registereventtypes", codes6);
		dateFieldController.put("id", "textFieldController");
		dateFieldController.put("viewdata", "textField_viewData_init_01");		
		GxtComponentMetaNodeModel node6=new GxtComponentMetaNodeModel(dateFieldController,8,9);

		List<GxtComponentMetaNodeModel> list=new ArrayList<GxtComponentMetaNodeModel>();
		list.add(node);
		list.add(node2);
		list.add(node3);
		list.add(node4);
		list.add(node5);
		list.add(node6);
		GxtComponentMetaModel gxtComponentMetaModel=new GxtComponentMetaModel(list);
		return GxtComponentControlerFactory.createGxtComponentController(gxtComponentMetaModel);
		
	}
	
	 *//**
	 * 动态创建树形控制器----窗口相关
	 *//*
	private Controller createDynamicWindowController() {
		
		//窗口+树
		Map<String , Object> windowController=new HashMap<String, Object>();
		windowController.put("component_controller_model_type", ComponentControllerEnum.WINDOW_CONTROLLER_MODEL);
		List<String> codes1 = new ArrayList<String>();
		codes1.add("0101");
		codes1.add("0301");		
		codes1.add("0003");
		codes1.add("0201");
		codes1.add("0401");
		codes1.add("0007");
		codes1.add("0008");
		
		windowController.put("id", "windowController");
		windowController.put("registereventtypes", codes1);
		windowController.put("viewdata", "window_viewData_init_01");		
		GxtComponentMetaNodeModel node=new GxtComponentMetaNodeModel(windowController,1,14);
		
		Map<String , Object> contentPanelController=new HashMap<String, Object>();
		contentPanelController.put("component_controller_model_type", ComponentControllerEnum.CONTENTPANEL_CONTROLLER_MODEL);
		List<String> codes2 = new ArrayList<String>();
		codes2.add("0201");
		codes2.add("0301");
		codes2.add("0401");
		codes2.add("0101");
		codes2.add("0007");
		codes2.add("0008");
		contentPanelController.put("registereventtypes", codes2);				
		contentPanelController.put("id", "contentPanelController");				
		contentPanelController.put("viewdata", "contentPanel_viewData_init_01");		
		GxtComponentMetaNodeModel node2=new GxtComponentMetaNodeModel(contentPanelController,2,13);
		
		Map<String , Object> menuBarController=new HashMap<String, Object>();
		menuBarController.put("component_controller_model_type", ComponentControllerEnum.MENUBAR_CONTROLLER_MODEL);
		List<String> codes3 = new ArrayList<String>();
		codes3.add("0201");
		codes3.add("0301");
		codes3.add("0401");
		codes3.add("0101");
		codes3.add("0007");
		codes3.add("0008");
		menuBarController.put("registereventtypes", codes3);
		menuBarController.put("id", "menuBarController");
		menuBarController.put("viewdata", "menuBar_viewData_init_01");		
		GxtComponentMetaNodeModel node3=new GxtComponentMetaNodeModel(menuBarController,3,4);
		
		Map<String , Object> toolBarController=new HashMap<String, Object>();
		toolBarController.put("component_controller_model_type", ComponentControllerEnum.TOOLBAR_CONTROLLER_MODEL);
		List<String> codes4 = new ArrayList<String>();
		codes4.add("0201");
		codes4.add("0301");
		codes4.add("0401");
		codes4.add("0101");
		codes4.add("0007");
		codes4.add("0008");
		toolBarController.put("registereventtypes", codes4);
		toolBarController.put("id", "toolBarController");
		toolBarController.put("viewdata", "toolBar_viewData_init_01");		
		GxtComponentMetaNodeModel node4=new GxtComponentMetaNodeModel(toolBarController,5,6);
		
		
		
		
		Map<String, Object> sumFormPanelController=new HashMap<String, Object>();
		sumFormPanelController.put("component_controller_model_type", ComponentControllerEnum.FORMPANEL_CONTROLLER_MODEL);
		List<String> codes45 = new ArrayList<String>();
		codes45.add("0201");
		codes45.add("0301");
		codes45.add("0401");
		codes45.add("0101");
		codes45.add("0007");
		codes45.add("0008");
		sumFormPanelController.put("registereventtypes", codes45);
		sumFormPanelController.put("id", "sumFormPanelController");
		sumFormPanelController.put("controllerdata", "sumFormPanel_controllerdata_init_01");		
		sumFormPanelController.put("viewdata", "sumFormPanel_viewData_init_01");		
		GxtComponentMetaNodeModel node45=new GxtComponentMetaNodeModel(sumFormPanelController, 7, 12);
		
		
		Map<String , Object> formPanelController=new HashMap<String, Object>();
		formPanelController.put("component_controller_model_type", ComponentControllerEnum.FORMSET_MODULE_CONTROLLER_MODEL);
		List<String> codes5 = new ArrayList<String>();
		codes5.add("0201");
		codes5.add("0301");
		codes5.add("0401");
		codes5.add("0101");
		codes5.add("0007");
		codes5.add("0008");
		formPanelController.put("registereventtypes", codes5);
		formPanelController.put("id", "formPanelController");
		formPanelController.put("controllerdata", "formPanel_controllerdata_init_01");		
		formPanelController.put("viewdata", "formPanel_viewData_init_01");		
		GxtComponentMetaNodeModel node5=new GxtComponentMetaNodeModel(formPanelController,8,9);
		
		Map<String , Object> treePanelModulesController=new HashMap<String, Object>();
		treePanelModulesController.put("component_controller_model_type", ComponentControllerEnum.TREEPANELMODULES_CONTROLLER_MODEL);
		List<String> codes6 = new ArrayList<String>();
		codes6.add("0401"); 
		codes6.add("0301"); 
		codes6.add("0201"); 
		codes6.add("0101");
		codes6.add("0007");
		codes6.add("0008");
		treePanelModulesController.put("registereventtypes", codes6);
		treePanelModulesController.put("id", "treePanelModulesController");
		treePanelModulesController.put("viewdata", "treePanelModules_viewData_init_01");		
		GxtComponentMetaNodeModel node6=new GxtComponentMetaNodeModel(treePanelModulesController,10,11);
		
		List<GxtComponentMetaNodeModel> list=new ArrayList<GxtComponentMetaNodeModel>();
		list.add(node);
		list.add(node2);
		list.add(node3);
		list.add(node4);
		list.add(node45);
		list.add(node5);
		list.add(node6);
		
		GxtComponentMetaModel gxtComponentMetaModel=new GxtComponentMetaModel(list);
		return GxtComponentControlerFactory.createGxtComponentController(gxtComponentMetaModel);
		
		
		
		//窗口+表格
		Map<String , Object> windowController=new HashMap<String, Object>();
		windowController.put("component_controller_model_type", ComponentControllerEnum.WINDOW_CONTROLLER_MODEL);
		List<String> codes1 = new ArrayList<String>();
		codes1.add("0101");
		codes1.add("0301");		
		codes1.add("0003");
		codes1.add("0201");
		codes1.add("0401");
		codes1.add("0007");
		codes1.add("0008");
		
		windowController.put("id", "windowController");
		windowController.put("registereventtypes", codes1);
		windowController.put("viewdata", "window_viewData_init_01");		
		GxtComponentMetaNodeModel node=new GxtComponentMetaNodeModel(windowController,1,16);
		
		Map<String , Object> contentPanelController=new HashMap<String, Object>();
		contentPanelController.put("component_controller_model_type", ComponentControllerEnum.CONTENTPANEL_CONTROLLER_MODEL);
		List<String> codes2 = new ArrayList<String>();
		codes2.add("0201");
		codes2.add("0301");
		codes2.add("0401");
		codes2.add("0101");
		codes2.add("0007");
		codes2.add("0008");
		contentPanelController.put("registereventtypes", codes2);				
		contentPanelController.put("id", "contentPanelController");				
		contentPanelController.put("viewdata", "contentPanel_viewData_init_01");		
		GxtComponentMetaNodeModel node2=new GxtComponentMetaNodeModel(contentPanelController,2,15);
		
		Map<String , Object> menuBarController=new HashMap<String, Object>();
		menuBarController.put("component_controller_model_type", ComponentControllerEnum.MENUBAR_CONTROLLER_MODEL);
		List<String> codes3 = new ArrayList<String>();
		codes3.add("0201");
		codes3.add("0301");
		codes3.add("0401");
		codes3.add("0101");
		codes3.add("0007");
		codes3.add("0008");
		menuBarController.put("registereventtypes", codes3);
		menuBarController.put("id", "menuBarController");
		menuBarController.put("viewdata", "menuBar_viewData_init_01");		
		GxtComponentMetaNodeModel node3=new GxtComponentMetaNodeModel(menuBarController,3,4);
		
		Map<String , Object> toolBarController=new HashMap<String, Object>();
		toolBarController.put("component_controller_model_type", ComponentControllerEnum.TOOLBAR_CONTROLLER_MODEL);
		List<String> codes4 = new ArrayList<String>();
		codes4.add("0201");
		codes4.add("0301");
		codes4.add("0401");
		codes4.add("0101");
		codes4.add("0007");
		codes4.add("0008");
		toolBarController.put("registereventtypes", codes4);
		toolBarController.put("id", "toolBarController");
		toolBarController.put("viewdata", "toolBar_viewData_init_01");		
		GxtComponentMetaNodeModel node4=new GxtComponentMetaNodeModel(toolBarController,5,6);
		
		
		
		
		Map<String, Object> sumFormPanelController=new HashMap<String, Object>();
		sumFormPanelController.put("component_controller_model_type", ComponentControllerEnum.FORMPANEL_CONTROLLER_MODEL);
		List<String> codes45 = new ArrayList<String>();
		codes45.add("0201");
		codes45.add("0301");
		codes45.add("0401");
		codes45.add("0101");
		codes45.add("0007");
		codes45.add("0008");
		sumFormPanelController.put("registereventtypes", codes45);
		sumFormPanelController.put("id", "sumFormPanelController");
		sumFormPanelController.put("controllerdata", "sumFormPanel_controllerdata_init_01");		
		sumFormPanelController.put("viewdata", "sumFormPanel_viewData_init_01");		
		GxtComponentMetaNodeModel node45=new GxtComponentMetaNodeModel(sumFormPanelController, 7, 14);
		
		
		Map<String , Object> formPanelController=new HashMap<String, Object>();
		formPanelController.put("component_controller_model_type", ComponentControllerEnum.FORMSET_MODULE_CONTROLLER_MODEL);
		List<String> codes5 = new ArrayList<String>();
		codes5.add("0201");
		codes5.add("0301");
		codes5.add("0401");
		codes5.add("0101");
		codes5.add("0007");
		codes5.add("0008");
		formPanelController.put("registereventtypes", codes5);
		formPanelController.put("id", "formPanelController");
		formPanelController.put("controllerdata", "formPanel_controllerdata_init_01");		
		formPanelController.put("viewdata", "formPanel_viewData_init_01");		
		GxtComponentMetaNodeModel node5=new GxtComponentMetaNodeModel(formPanelController,8,9);
		
		Map<String , Object> textFieldController=new HashMap<String, Object>();
		textFieldController.put("component_controller_model_type", ComponentControllerEnum.GRIDSETMODULES_CONTROLLER_MODEL);
		List<String> codes6 = new ArrayList<String>();
		codes6.add("0401"); 
		codes6.add("0301"); 
		codes6.add("0201"); 
		codes6.add("0101");
		codes6.add("0007");
		codes6.add("0008");
		textFieldController.put("registereventtypes", codes6);
		textFieldController.put("id", "textFieldController");
		textFieldController.put("viewdata", "textField_viewData_init_01");		
		GxtComponentMetaNodeModel node6=new GxtComponentMetaNodeModel(textFieldController,10,13);
		
		Map<String , Object> dataLoadController=new HashMap<String, Object>();
		dataLoadController.put("component_controller_model_type", ComponentControllerEnum.GRID_DATALOAD_CONTROLLER_MODEL);
		List<String> codes12222 = new ArrayList<String>();
		codes12222.add("0101");
		codes12222.add("0301");		
		codes12222.add("0003");
		codes12222.add("0201");
		codes12222.add("0401");
		
		
		dataLoadController.put("id", "dataLoadController01");
		dataLoadController.put("registereventtypes", codes12222);
		//windowController.put("viewdata", "window_viewData_init_01");		
		GxtComponentMetaNodeModel node62=new GxtComponentMetaNodeModel(dataLoadController,11,12);
		
//		Map<String , Object> textFieldController=new HashMap<String, Object>();
//		textFieldController.put("component_controller_model_type", ComponentControllerEnum.TEXTFIELD_CONTROLLER_MODEL);
//		List<String> codes6 = new ArrayList<String>();
//		codes6.add("0301"); 
//		codes6.add("0201"); 
//		codes6.add("0101");
//		codes6.add("0007");
//		codes6.add("0008");
//		textFieldController.put("registereventtypes", codes6);
//		textFieldController.put("id", "textFieldController");
//		textFieldController.put("viewdata", "textField_viewData_init_01");		
//		GxtComponentMetaNodeModel node6=new GxtComponentMetaNodeModel(textFieldController,8,9);
//		
//		Map<String , Object> comboBoxController=new HashMap<String, Object>();
//		comboBoxController.put("component_controller_model_type", ComponentControllerEnum.COMBOBOX_CONTROLLER_MODEL);
//		List<String> codes6 = new ArrayList<String>();
//		codes6.add("0301"); 
//		codes6.add("0201"); 
//		codes6.add("0101");
//		codes6.add("0007");
//		codes6.add("0008");
//		comboBoxController.put("registereventtypes", codes6);
//		comboBoxController.put("id", "textFieldController");
//		comboBoxController.put("viewdata", "textField_viewData_init_01");		
//		GxtComponentMetaNodeModel node6=new GxtComponentMetaNodeModel(comboBoxController,8,9);
//		
//		Map<String , Object> dateFieldController=new HashMap<String, Object>();
//		dateFieldController.put("component_controller_model_type", ComponentControllerEnum.DATEFIELD_CONTROLLER_MODEL);
//		List<String> codes6 = new ArrayList<String>();
//		codes6.add("0301"); 
//		codes6.add("0201"); 
//		codes6.add("0101");
//		codes6.add("0007");
//		codes6.add("0008");
//		dateFieldController.put("registereventtypes", codes6);
//		dateFieldController.put("id", "textFieldController");
//		dateFieldController.put("viewdata", "textField_viewData_init_01");		
//		GxtComponentMetaNodeModel node6=new GxtComponentMetaNodeModel(dateFieldController,8,9);

		List<GxtComponentMetaNodeModel> list=new ArrayList<GxtComponentMetaNodeModel>();
		list.add(node);
		list.add(node2);
		list.add(node3);
		list.add(node4);
		list.add(node45);
		list.add(node5);
		list.add(node6);
		list.add(node62);
		GxtComponentMetaModel gxtComponentMetaModel=new GxtComponentMetaModel(list);
		return GxtComponentControlerFactory.createGxtComponentController(gxtComponentMetaModel);
		
	}
	
private Controller createDynamicWindowController2() {
		
		//窗口+树
		Map<String , Object> windowController=new HashMap<String, Object>();
		windowController.put("component_controller_model_type", ComponentControllerEnum.WINDOW_CONTROLLER_MODEL);
		List<String> codes1 = new ArrayList<String>();
		codes1.add("0101");
		codes1.add("0301");		
		codes1.add("0003");
		codes1.add("0201");
		codes1.add("0401");
		codes1.add("0007");
		codes1.add("0008");
		
		windowController.put("id", "windowController");
		windowController.put("registereventtypes", codes1);
		windowController.put("viewdata", "window_viewData_init_01");		
		GxtComponentMetaNodeModel node=new GxtComponentMetaNodeModel(windowController,1,14);
		
		Map<String , Object> contentPanelController=new HashMap<String, Object>();
		contentPanelController.put("component_controller_model_type", ComponentControllerEnum.CONTENTPANEL_CONTROLLER_MODEL);
		List<String> codes2 = new ArrayList<String>();
		codes2.add("0201");
		codes2.add("0301");
		codes2.add("0401");
		codes2.add("0101");
		codes2.add("0007");
		codes2.add("0008");
		contentPanelController.put("registereventtypes", codes2);				
		contentPanelController.put("id", "contentPanelController");				
		contentPanelController.put("viewdata", "contentPanel_viewData_init_01");		
		GxtComponentMetaNodeModel node2=new GxtComponentMetaNodeModel(contentPanelController,2,13);
		
		Map<String , Object> menuBarController=new HashMap<String, Object>();
		menuBarController.put("component_controller_model_type", ComponentControllerEnum.MENUBAR_CONTROLLER_MODEL);
		List<String> codes3 = new ArrayList<String>();
		codes3.add("0201");
		codes3.add("0301");
		codes3.add("0401");
		codes3.add("0101");
		codes3.add("0007");
		codes3.add("0008");
		menuBarController.put("registereventtypes", codes3);
		menuBarController.put("id", "menuBarController");
		menuBarController.put("viewdata", "menuBar_viewData_init_01");		
		GxtComponentMetaNodeModel node3=new GxtComponentMetaNodeModel(menuBarController,3,4);
		
		Map<String , Object> toolBarController=new HashMap<String, Object>();
		toolBarController.put("component_controller_model_type", ComponentControllerEnum.TOOLBAR_CONTROLLER_MODEL);
		List<String> codes4 = new ArrayList<String>();
		codes4.add("0201");
		codes4.add("0301");
		codes4.add("0401");
		codes4.add("0101");
		codes4.add("0007");
		codes4.add("0008");
		toolBarController.put("registereventtypes", codes4);
		toolBarController.put("id", "toolBarController");
		toolBarController.put("viewdata", "toolBar_viewData_init_01");		
		GxtComponentMetaNodeModel node4=new GxtComponentMetaNodeModel(toolBarController,5,6);
		
		
		
		
		Map<String, Object> sumFormPanelController=new HashMap<String, Object>();
		sumFormPanelController.put("component_controller_model_type", ComponentControllerEnum.FORMPANEL_CONTROLLER_MODEL);
		List<String> codes45 = new ArrayList<String>();
		codes45.add("0201");
		codes45.add("0301");
		codes45.add("0401");
		codes45.add("0101");
		codes45.add("0007");
		codes45.add("0008");
		sumFormPanelController.put("registereventtypes", codes45);
		sumFormPanelController.put("id", "sumFormPanelController");
		sumFormPanelController.put("controllerdata", "sumFormPanel_controllerdata_init_01");		
		sumFormPanelController.put("viewdata", "sumFormPanel_viewData_init_01");		
		GxtComponentMetaNodeModel node45=new GxtComponentMetaNodeModel(sumFormPanelController, 7, 12);
		
		
		Map<String , Object> formPanelController=new HashMap<String, Object>();
		formPanelController.put("component_controller_model_type", ComponentControllerEnum.FORMSET_MODULE_CONTROLLER_MODEL);
		List<String> codes5 = new ArrayList<String>();
		codes5.add("0201");
		codes5.add("0301");
		codes5.add("0401");
		codes5.add("0101");
		codes5.add("0007");
		codes5.add("0008");
		formPanelController.put("registereventtypes", codes5);
		formPanelController.put("id", "formPanelController");
		formPanelController.put("controllerdata", "formPanel_controllerdata_init_01");		
		formPanelController.put("viewdata", "formPanel_viewData_init_01");		
		GxtComponentMetaNodeModel node5=new GxtComponentMetaNodeModel(formPanelController,8,9);
		
		Map<String , Object> treePanelModulesController=new HashMap<String, Object>();
		treePanelModulesController.put("component_controller_model_type", ComponentControllerEnum.TREEPANELMODULES_CONTROLLER_MODEL);
		List<String> codes6 = new ArrayList<String>();
		codes6.add("0401"); 
		codes6.add("0301"); 
		codes6.add("0201"); 
		codes6.add("0101");
		codes6.add("0007");
		codes6.add("0008");
		treePanelModulesController.put("registereventtypes", codes6);
		treePanelModulesController.put("id", "treePanelModulesController");
		treePanelModulesController.put("viewdata", "treePanelModules_viewData_init_01");		
		GxtComponentMetaNodeModel node6=new GxtComponentMetaNodeModel(treePanelModulesController,10,11);
		
		List<GxtComponentMetaNodeModel> list=new ArrayList<GxtComponentMetaNodeModel>();
		list.add(node);
		list.add(node2);
		list.add(node3);
		list.add(node4);
		list.add(node45);
		list.add(node5);
		list.add(node6);
		
		GxtComponentMetaModel gxtComponentMetaModel=new GxtComponentMetaModel(list);
		return GxtComponentControlerFactory.createGxtComponentController(gxtComponentMetaModel);
		
		
		
		//窗口+表格
		Map<String , Object> windowController=new HashMap<String, Object>();
		windowController.put("component_controller_model_type", ComponentControllerEnum.WINDOW_CONTROLLER_MODEL);
		List<String> codes1 = new ArrayList<String>();
		codes1.add("0101");
		codes1.add("0301");		
		codes1.add("0003");
		codes1.add("0201");
		codes1.add("0401");
		codes1.add("0007");
		codes1.add("0008");
		
		windowController.put("id", "windowController");
		windowController.put("registereventtypes", codes1);
		windowController.put("viewdata", "window_viewData_init_01");		
		GxtComponentMetaNodeModel node=new GxtComponentMetaNodeModel(windowController,1,16);
		
		Map<String , Object> contentPanelController=new HashMap<String, Object>();
		contentPanelController.put("component_controller_model_type", ComponentControllerEnum.CONTENTPANEL_CONTROLLER_MODEL);
		List<String> codes2 = new ArrayList<String>();
		codes2.add("0201");
		codes2.add("0301");
		codes2.add("0401");
		codes2.add("0101");
		codes2.add("0007");
		codes2.add("0008");
		contentPanelController.put("registereventtypes", codes2);				
		contentPanelController.put("id", "contentPanelController");				
		contentPanelController.put("viewdata", "contentPanel_viewData_init_01");		
		GxtComponentMetaNodeModel node2=new GxtComponentMetaNodeModel(contentPanelController,2,15);
		
		Map<String , Object> menuBarController=new HashMap<String, Object>();
		menuBarController.put("component_controller_model_type", ComponentControllerEnum.MENUBAR_CONTROLLER_MODEL);
		List<String> codes3 = new ArrayList<String>();
		codes3.add("0201");
		codes3.add("0301");
		codes3.add("0401");
		codes3.add("0101");
		codes3.add("0007");
		codes3.add("0008");
		menuBarController.put("registereventtypes", codes3);
		menuBarController.put("id", "menuBarController");
		menuBarController.put("viewdata", "menuBar_viewData_init_01");		
		GxtComponentMetaNodeModel node3=new GxtComponentMetaNodeModel(menuBarController,3,4);
		
		Map<String , Object> toolBarController=new HashMap<String, Object>();
		toolBarController.put("component_controller_model_type", ComponentControllerEnum.TOOLBAR_CONTROLLER_MODEL);
		List<String> codes4 = new ArrayList<String>();
		codes4.add("0201");
		codes4.add("0301");
		codes4.add("0401");
		codes4.add("0101");
		codes4.add("0007");
		codes4.add("0008");
		toolBarController.put("registereventtypes", codes4);
		toolBarController.put("id", "toolBarController");
		toolBarController.put("viewdata", "toolBar_viewData_init_01");		
		GxtComponentMetaNodeModel node4=new GxtComponentMetaNodeModel(toolBarController,5,6);
		
		
		
		
		Map<String, Object> sumFormPanelController=new HashMap<String, Object>();
		sumFormPanelController.put("component_controller_model_type", ComponentControllerEnum.FORMPANEL_CONTROLLER_MODEL);
		List<String> codes45 = new ArrayList<String>();
		codes45.add("0201");
		codes45.add("0301");
		codes45.add("0401");
		codes45.add("0101");
		codes45.add("0007");
		codes45.add("0008");
		sumFormPanelController.put("registereventtypes", codes45);
		sumFormPanelController.put("id", "sumFormPanelController");
		sumFormPanelController.put("controllerdata", "sumFormPanel_controllerdata_init_01");		
		sumFormPanelController.put("viewdata", "sumFormPanel_viewData_init_01");		
		GxtComponentMetaNodeModel node45=new GxtComponentMetaNodeModel(sumFormPanelController, 7, 14);
		
		
		Map<String , Object> formPanelController=new HashMap<String, Object>();
		formPanelController.put("component_controller_model_type", ComponentControllerEnum.FORMSET_MODULE_CONTROLLER_MODEL);
		List<String> codes5 = new ArrayList<String>();
		codes5.add("0201");
		codes5.add("0301");
		codes5.add("0401");
		codes5.add("0101");
		codes5.add("0007");
		codes5.add("0008");
		formPanelController.put("registereventtypes", codes5);
		formPanelController.put("id", "formPanelController");
		formPanelController.put("controllerdata", "formPanel_controllerdata_init_01");		
		formPanelController.put("viewdata", "formPanel_viewData_init_01");		
		GxtComponentMetaNodeModel node5=new GxtComponentMetaNodeModel(formPanelController,8,9);
		
		Map<String , Object> textFieldController=new HashMap<String, Object>();
		textFieldController.put("component_controller_model_type", ComponentControllerEnum.GRIDSETMODULES_CONTROLLER_MODEL);
		List<String> codes6 = new ArrayList<String>();
		codes6.add("0401"); 
		codes6.add("0301"); 
		codes6.add("0201"); 
		codes6.add("0101");
		codes6.add("0007");
		codes6.add("0008");
		textFieldController.put("registereventtypes", codes6);
		textFieldController.put("id", "textFieldController");
		textFieldController.put("viewdata", "textField_viewData_init_01");		
		GxtComponentMetaNodeModel node6=new GxtComponentMetaNodeModel(textFieldController,10,13);
		
		Map<String , Object> dataLoadController=new HashMap<String, Object>();
		dataLoadController.put("component_controller_model_type", ComponentControllerEnum.GRID_DATALOAD_CONTROLLER_MODEL);
		List<String> codes12222 = new ArrayList<String>();
		codes12222.add("0101");
		codes12222.add("0301");		
		codes12222.add("0003");
		codes12222.add("0201");
		codes12222.add("0401");
		
		
		dataLoadController.put("id", "dataLoadController01");
		dataLoadController.put("registereventtypes", codes12222);
		//windowController.put("viewdata", "window_viewData_init_01");		
		GxtComponentMetaNodeModel node62=new GxtComponentMetaNodeModel(dataLoadController,11,12);
		
//		Map<String , Object> textFieldController=new HashMap<String, Object>();
//		textFieldController.put("component_controller_model_type", ComponentControllerEnum.TEXTFIELD_CONTROLLER_MODEL);
//		List<String> codes6 = new ArrayList<String>();
//		codes6.add("0301"); 
//		codes6.add("0201"); 
//		codes6.add("0101");
//		codes6.add("0007");
//		codes6.add("0008");
//		textFieldController.put("registereventtypes", codes6);
//		textFieldController.put("id", "textFieldController");
//		textFieldController.put("viewdata", "textField_viewData_init_01");		
//		GxtComponentMetaNodeModel node6=new GxtComponentMetaNodeModel(textFieldController,8,9);
//		
//		Map<String , Object> comboBoxController=new HashMap<String, Object>();
//		comboBoxController.put("component_controller_model_type", ComponentControllerEnum.COMBOBOX_CONTROLLER_MODEL);
//		List<String> codes6 = new ArrayList<String>();
//		codes6.add("0301"); 
//		codes6.add("0201"); 
//		codes6.add("0101");
//		codes6.add("0007");
//		codes6.add("0008");
//		comboBoxController.put("registereventtypes", codes6);
//		comboBoxController.put("id", "textFieldController");
//		comboBoxController.put("viewdata", "textField_viewData_init_01");		
//		GxtComponentMetaNodeModel node6=new GxtComponentMetaNodeModel(comboBoxController,8,9);
//		
//		Map<String , Object> dateFieldController=new HashMap<String, Object>();
//		dateFieldController.put("component_controller_model_type", ComponentControllerEnum.DATEFIELD_CONTROLLER_MODEL);
//		List<String> codes6 = new ArrayList<String>();
//		codes6.add("0301"); 
//		codes6.add("0201"); 
//		codes6.add("0101");
//		codes6.add("0007");
//		codes6.add("0008");
//		dateFieldController.put("registereventtypes", codes6);
//		dateFieldController.put("id", "textFieldController");
//		dateFieldController.put("viewdata", "textField_viewData_init_01");		
//		GxtComponentMetaNodeModel node6=new GxtComponentMetaNodeModel(dateFieldController,8,9);

		List<GxtComponentMetaNodeModel> list=new ArrayList<GxtComponentMetaNodeModel>();
		list.add(node);
		list.add(node2);
		list.add(node3);
		list.add(node4);
		list.add(node45);
		list.add(node5);
		list.add(node6);
		list.add(node62);
		GxtComponentMetaModel gxtComponentMetaModel=new GxtComponentMetaModel(list);
		return GxtComponentControlerFactory.createGxtComponentController(gxtComponentMetaModel);
		
	}
	
	 *//**
	 * 动态创建树形控制器----dataLoadController相关
	 *//*
	private Controller createDataLoadController() {
		Map<String , Object> dataLoadController=new HashMap<String, Object>();
		dataLoadController.put("component_controller_model_type", ComponentControllerEnum.GRID_DATALOAD_CONTROLLER_MODEL);
		List<String> codes12222 = new ArrayList<String>();
		codes12222.add("0101");
		codes12222.add("0301");		
		codes12222.add("0003");
		codes12222.add("0201");
		codes12222.add("0401");
		
		
		dataLoadController.put("id", "dataLoadController");
		dataLoadController.put("registereventtypes", codes12222);
		//windowController.put("viewdata", "window_viewData_init_01");		
		GxtComponentMetaNodeModel node=new GxtComponentMetaNodeModel(dataLoadController);
		
		

		List<GxtComponentMetaNodeModel> list=new ArrayList<GxtComponentMetaNodeModel>();
		list.add(node);
	
		GxtComponentMetaModel gxtComponentMetaModel=new GxtComponentMetaModel(list);
		return GxtComponentControlerFactory.createGxtComponentController(gxtComponentMetaModel);
		
	}
	
	
	 *//**
	 * 动态创建树形控制器----窗口相关
	 *//*
	private Controller createDynamicController3() {
		Map<String , Object> windowController=new HashMap<String, Object>();
		windowController.put("component_controller_model_type", ComponentControllerEnum.WINDOW_CONTROLLER_MODEL);
		List<String> codes1 = new ArrayList<String>();
		codes1.add("0101");
		codes1.add("0301");		
		codes1.add("0003");
		codes1.add("0201");
		//codes1.add("0005");
		codes1.add("0007");
		codes1.add("0008");
		
		windowController.put("id", "windowController");
		windowController.put("registereventtypes", codes1);
		windowController.put("viewdata", "window_viewData_init_01");		
		GxtComponentMetaNodeModel node=new GxtComponentMetaNodeModel(windowController,1,14);
		
		Map<String , Object> contentPanelController=new HashMap<String, Object>();
		contentPanelController.put("component_controller_model_type", ComponentControllerEnum.CONTENTPANEL_CONTROLLER_MODEL);
		List<String> codes2 = new ArrayList<String>();
		codes2.add("0201");
		codes2.add("0301");
		codes2.add("0101");
		codes2.add("0007");
		codes2.add("0008");
		contentPanelController.put("registereventtypes", codes2);				
		contentPanelController.put("id", "contentPanelController");				
		contentPanelController.put("viewdata", "contentPanel_viewData_init_01");		
		GxtComponentMetaNodeModel node2=new GxtComponentMetaNodeModel(contentPanelController,2,13);
		
		Map<String , Object> menuBarController=new HashMap<String, Object>();
		menuBarController.put("component_controller_model_type", ComponentControllerEnum.MENUBAR_CONTROLLER_MODEL);
		List<String> codes3 = new ArrayList<String>();
		codes3.add("0201");
		codes3.add("0301");
		codes3.add("0101");
		codes3.add("0007");
		codes3.add("0008");
		menuBarController.put("registereventtypes", codes3);
		menuBarController.put("id", "menuBarController");
		menuBarController.put("viewdata", "menuBar_viewData_init_01");		
		GxtComponentMetaNodeModel node3=new GxtComponentMetaNodeModel(menuBarController,3,4);
		
		Map<String , Object> toolBarController=new HashMap<String, Object>();
		toolBarController.put("component_controller_model_type", ComponentControllerEnum.TOOLBAR_CONTROLLER_MODEL);
		List<String> codes4 = new ArrayList<String>();
		codes4.add("0201");
		codes4.add("0301");
		codes4.add("0101");
		codes4.add("0007");
		codes4.add("0008");
		toolBarController.put("registereventtypes", codes4);
		toolBarController.put("id", "toolBarController");
		toolBarController.put("viewdata", "toolBar_viewData_init_01");		
		GxtComponentMetaNodeModel node4=new GxtComponentMetaNodeModel(toolBarController,5,6);
		
		//创建提交和取消按钮
		Map<String, Object> btnSubmit=new HashMap<String, Object>();
		btnSubmit.put("component_model_type", ComponentTypeEnum.BUTTON_MODEL);
		btnSubmit.put("text", "确定");
		GxtComponentMetaNodeModel btnSubmit1=new GxtComponentMetaNodeModel(btnSubmit);
		
		Map<String, Object> btnquxiao=new HashMap<String, Object>();
		btnquxiao.put("component_model_type", ComponentTypeEnum.BUTTON_MODEL);
		btnquxiao.put("text", "取消");
		GxtComponentMetaNodeModel btn1=new GxtComponentMetaNodeModel(btnquxiao);
		
		List<GxtComponentMetaNodeModel> list1=new ArrayList<GxtComponentMetaNodeModel>();
		list1.add(btnSubmit1);
		list1.add(btn1);
		Map<String, Object> sumFormPanelController=new HashMap<String, Object>();
		List<String> codes45 = new ArrayList<String>();
		codes45.add("0201");
		codes45.add("0301");
		codes45.add("0101");
		codes45.add("0007");
		codes45.add("0008");
		sumFormPanelController.put("registereventtypes", codes45);
		sumFormPanelController.put("id", "sumFormPanelController");
		sumFormPanelController.put("controllerdata", "sumFormPanel_controllerdata_init_01");		
		sumFormPanelController.put("viewdata", "sumFormPanel_viewData_init_01");		
		GxtComponentMetaNodeModel node45=new GxtComponentMetaNodeModel(sumFormPanelController, 7, 12);
		
		
		Map<String , Object> formPanelController=new HashMap<String, Object>();
		formPanelController.put("component_controller_model_type", ComponentControllerEnum.FORMSET_MODULE_CONTROLLER_MODEL);
		List<String> codes5 = new ArrayList<String>();
		codes5.add("0201");
		codes5.add("0301");
		codes5.add("0101");
		codes5.add("0007");
		codes5.add("0008");
		formPanelController.put("registereventtypes", codes5);
		formPanelController.put("id", "formPanelController");
		formPanelController.put("controllerdata", "formPanel_controllerdata_init_01");		
		formPanelController.put("viewdata", "formPanel_viewData_init_01");		
		GxtComponentMetaNodeModel node5=new GxtComponentMetaNodeModel(formPanelController,8,9);
		
		Map<String , Object> textFieldController=new HashMap<String, Object>();
	//??
			textFieldController.put("component_controller_model_type", ComponentControllerEnum.GRID_CONTROLLER_MODEL);
		List<String> codes6 = new ArrayList<String>();
		codes6.add("0301"); 
		codes6.add("0201"); 
		codes6.add("0101");
		codes6.add("0007");
		codes6.add("0008");
		textFieldController.put("registereventtypes", codes6);
		textFieldController.put("id", "textFieldController");
		textFieldController.put("viewdata", "textField_viewData_init_01");		
		GxtComponentMetaNodeModel node6=new GxtComponentMetaNodeModel(textFieldController,10,11);
		
		Map<String , Object> textFieldController=new HashMap<String, Object>();
		textFieldController.put("component_controller_model_type", ComponentControllerEnum.TEXTFIELD_CONTROLLER_MODEL);
		List<String> codes6 = new ArrayList<String>();
		codes6.add("0301"); 
		codes6.add("0201"); 
		codes6.add("0101");
		codes6.add("0007");
		codes6.add("0008");
		textFieldController.put("registereventtypes", codes6);
		textFieldController.put("id", "textFieldController");
		textFieldController.put("viewdata", "textField_viewData_init_01");		
		GxtComponentMetaNodeModel node6=new GxtComponentMetaNodeModel(textFieldController,8,9);
		
		Map<String , Object> comboBoxController=new HashMap<String, Object>();
		comboBoxController.put("component_controller_model_type", ComponentControllerEnum.COMBOBOX_CONTROLLER_MODEL);
		List<String> codes6 = new ArrayList<String>();
		codes6.add("0301"); 
		codes6.add("0201"); 
		codes6.add("0101");
		codes6.add("0007");
		codes6.add("0008");
		comboBoxController.put("registereventtypes", codes6);
		comboBoxController.put("id", "textFieldController");
		comboBoxController.put("viewdata", "textField_viewData_init_01");		
		GxtComponentMetaNodeModel node6=new GxtComponentMetaNodeModel(comboBoxController,8,9);
		
		Map<String , Object> dateFieldController=new HashMap<String, Object>();
		dateFieldController.put("component_controller_model_type", ComponentControllerEnum.DATEFIELD_CONTROLLER_MODEL);
		List<String> codes6 = new ArrayList<String>();
		codes6.add("0301"); 
		codes6.add("0201"); 
		codes6.add("0101");
		codes6.add("0007");
		codes6.add("0008");
		dateFieldController.put("registereventtypes", codes6);
		dateFieldController.put("id", "textFieldController");
		dateFieldController.put("viewdata", "textField_viewData_init_01");		
		GxtComponentMetaNodeModel node6=new GxtComponentMetaNodeModel(dateFieldController,8,9);

		List<GxtComponentMetaNodeModel> list=new ArrayList<GxtComponentMetaNodeModel>();
		list.add(node);
		list.add(node2);
		list.add(node3);
		list.add(node4);
		list.add(node5);
		list.add(node6);
		GxtComponentMetaModel gxtComponentMetaModel=new GxtComponentMetaModel(list);
		return GxtComponentControlerFactory.createGxtComponentController(gxtComponentMetaModel);
		
	}*/

	


	@Override
	protected void handleEvent(AppEvent event) {
		if (event.getType() == AppEvents.DESKTOP_USER_LOGIN) {
			
			if (event.getData("eventName")!=null) {
				MyLoggerUtil.printPresenterDebug(this.getClass(), event.getData(MvcConstants.EVENT_NAME).toString());
				//Log.debug(GwtLogHelper.printEventResponseByDebug(this.getClass(), event.getData("eventName").toString()));
			}else {
				MyLoggerUtil.printWarn(this.getClass(), "eventName is null,event type is "+event.getType());
			}	      				       						 
			RootPanel.get("body").add(display.getLoginDialog(), 350, 150);
			//display.show();
			//display.getLoginDialog().show();
			//LoginDialog loginDialog = display.getLoginDialog();loginDialog.show();
			
		}
		
		 
		    if (event.getType() == AppEvents.DESKTOP_UER_LOGIN_VALIDATE) {
		//	  final GxtComponentMetaModel gxtComponentMetaModel = this.getDesktopMetaModel();
			//    final Controller desktopcontroller = this.createDynamicDesktopController();
			  //  final Controller windowController = this.createDynamicWindowController2();
			    //final Controller dataLoadController = this.createDataLoadController();
			  /**
				 *  LoginDialog dialog = new LoginDialog();   
				 *  通过Rpc，提交dialog获得的用户名密码
				 *  获得返回值
				 *  如果是ture，加载需要的控制器，？
				 *  如果是false，重定向到LoginDialog
				 */
			 //GWT.log("LoginPresenter reponses the event named AppEvents.DESKTOP_UER_LOGIN_VALIDATE");
			    TextField<String> username = display.getUserNameTextField();
			    TextField<String> password = display.getPasswordTextField();
			    GWT.log("登录窗口中，用户名为"+username.getValue()+" ;密码为"+password.getValue());
			    System.err.println("$$$$ username " +username.getValue());;
			    System.err.println("$$$$ password " +password.getValue());;
			    
			  final GxtToSeamServiceParameter gxtToSeamServiceParameter = new GxtToSeamServiceParameter();
				gxtToSeamServiceParameter.setServiceComponentName("componentControllerMetaModelService");
				gxtToSeamServiceParameter.setServiceMethodName("findAllComponentControllerMetaModels");
				ModelData[] methodArguments2 = new BaseModelData[1];
				methodArguments2[0] = new BaseModel();
				methodArguments2[0].set("username", username.getValue());
				methodArguments2[0].set("password", password.getValue());
				gxtToSeamServiceParameter.setMethodArguments(null );
					display.getLoginDialog().hide();
					final MessageBox waittingMessageBox = MessageBox.wait("用 户 登 录 ",   
				            "Loading your setting and data, please wait......", "Logining...");  
					serviceInvoker.callService(gxtToSeamServiceParameter,
							new AsyncCallback<GxtToSeamServiceResult>() {

								@Override
								public void onSuccess(GxtToSeamServiceResult result) {
								List<GxtComponentControllerMetaModel> bmBaseModels = new DeaktopInitService().validateLogin0(null);						
								BaseModel modelData = (BaseModel)result.getResult();
								//bmBaseModels = modelData.get("listOfModelData");									
									/*List<GxtComponentControllerMetaModel> bmBaseModels = new LinkedList<GxtComponentControllerMetaModel>();						
									
									BaseModel modelData = result.getResult();
									BaseModel myBaseModel = (BaseModel)result.getResult();
									GxtComponentControllerMetaModel gxtComponentControllerMetaModel = null;
									if (myBaseModel.get(MetaDataConstants.GXT_COMPONENT_CONTROLLER_METAMODEL) instanceof GxtComponentControllerMetaModel) {										
										 gxtComponentControllerMetaModel =myBaseModel.get(MetaDataConstants.GXT_COMPONENT_CONTROLLER_METAMODEL);
									}else {
										Window.alert("xxxxxxxxxxx");
										//gxtComponentControllerMetaModel.setBaseModel((BaseModel)myBaseModel.get(MetaDataConstants.GXT_COMPONENT_CONTROLLER_METAMODEL));
									}
									com.google.gwt.user.client.Window.alert("jjjjjjjj"+gxtComponentControllerMetaModel);

									bmBaseModels.add(gxtComponentControllerMetaModel);*/
									
									waittingMessageBox.close();

									for (GxtComponentControllerMetaModel componentControllerMetaModel : bmBaseModels) {
										
//										if (password.getValue().equals("xxxxx")) {
										if (false) {
											//box.close();
											MessageBox.alert("Access Denied", "您的用户名或密码错误，请重新登录", null);
											//dialog = new LoginDialog();
											//dialog.getState().clear();
											//dialog.show();
											//Dispatcher.forwardEvent(AppEvents.DESKTOP_UER_LOGIN_FAILURE,new HashMap<String, Object>());

										}else {
											Window.alert("222222222222ccccccccccccccccc");
											Controller controller = GxtComponentControlerFactory.createGxtComponentController(componentControllerMetaModel);
											Dispatcher.get().addController(controller);
											
											/*if (controller instanceof WindowController) {
												Map<String, Object> map2= new HashMap<String, Object>();										 	
												Dispatcher.get().dispatch(AppEvents.LOAD_DATA_EVENT,map2);
											}*/											
											//box.close();
											//Dispatcher.forwardEvent(AppEvents.DESKTOP_INIT_FOR_LOGGED_IN_USER,new HashMap<String, Object>());
										}
									}											
									
								/* Dispatcher.get().addController(desktopcontroller);		    		  
						    	 Dispatcher.get().addController(windowController);				    		  				    		  
						    		  Dispatcher.forwardEvent(AppEvents.DESKTOP_INIT_FOR_LOGGED_IN_USER);*/
								
								}

								@Override
								public void onFailure(Throwable caught) {
									waittingMessageBox.close();
									MessageBox.alert("Access Denied", "系统登录失败，请稍后重试 !", null);
									System.out.println("#### Rpc Exception is ####"+caught +" When get the List<GxtComponentMetaNodeModel>");
									caught.printStackTrace();
								}
							});
				
		//}
	  }
	}
	
	
	
	//创建桌面快捷方式的代码	
	private GxtComponentControllerMetaModel createDynamicDesktopController3() {

		Map<String , Object> desktopController=new HashMap<String, Object>();
//		desktopController.put("component_controller_model_type", ComponentControllerEnum.DESKTOP_CONTROL_MODEL);
		desktopController.put(MetaDataConstants.COMPONENT_CONTROLLER_MODEL_TYPE_INDEX, ComponentControllerEnum.DESKTOP_CONTROLLOR_MODEL.ordinal());
		Set<GxtAppEventType> codes1 = new HashSet<GxtAppEventType>();
		new GxtAppEventType("0003");
		codes1.add(new GxtAppEventType("0003"));
		codes1.add(new GxtAppEventType("0002"));
		codes1.add(new GxtAppEventType("0005"));
		desktopController.put(MetaDataConstants.APP_EVENT_TYPES, codes1);
		//desktopController.put("registereventtypes", codes1);
		//desktopController.put("id", "desktopController");
		desktopController.put(MetaDataConstants.COMPONENT_CONTROLLER_ID, "desktopController");
		GxtComponentControllerMetaNodeModel node=new GxtComponentControllerMetaNodeModel(desktopController,1,4);
		
		Map<String , Object> shortcutController=new HashMap<String, Object>();
//		shortcutController.put("component_controller_model_type", ComponentControllerEnum.SHORTCUT_CONTROLLER_MODEL);
		shortcutController.put(MetaDataConstants.COMPONENT_CONTROLLER_MODEL_TYPE_INDEX, ComponentControllerEnum.SHORTCUT_CONTROLLER_MODEL.ordinal());
		Set<GxtAppEventType> codes2 = new HashSet<GxtAppEventType>();
		new GxtAppEventType("0003");
		codes2.add(new GxtAppEventType("0003"));
		codes2.add(new GxtAppEventType("0002"));
		codes2.add(new GxtAppEventType("0005"));
		shortcutController.put(MetaDataConstants.APP_EVENT_TYPES, codes2);
		shortcutController.put(MetaDataConstants.COMPONENT_CONTROLLER_ID, "shortcutController01");
		shortcutController.put("viewdata", "shortcut_viewData_init_01");	
//		shortcutController.put("gxtcomponentmetanodemodel", this.getShortcutGxtComponentMetaNodeModel());		
		shortcutController.put(MetaDataConstants.GXT_COMPONENT__METANODEMODEL, this.getShortcutGxtComponentMetaNodeModel());		
		GxtComponentControllerMetaNodeModel node2=new GxtComponentControllerMetaNodeModel(shortcutController,2,3);
				
		List<GxtComponentControllerMetaNodeModel> list=new ArrayList<GxtComponentControllerMetaNodeModel>();
		list.add(node);
		list.add(node2);		

		GxtComponentControllerMetaModel gxtComponentMetaModel=new GxtComponentControllerMetaModel(list);
				
		return gxtComponentMetaModel;
		

	}
	private GxtComponentMetaNodeModel getShortcutGxtComponentMetaNodeModel() {
		Map<String, Object> map2=new HashMap<String, Object>();
		//map2.put("component_model_type", ComponentTypeEnum.SHORTCUT_MODEL);
		map2.put("component_model_type_index", ComponentTypeEnum.SHORTCUT_MODEL.ordinal());
		//TODO map2.put("appEventType", AppEvents.DESKTOP_SHORTCUT_ONCLICK_INIT);
			Map<String,Object> RegisterEventTypeDatas = new HashMap<String, Object>();
			//添加需要监听的事件类型，指定由某一个控制器响应，控制器内部应该如何响应（附加参数和数据）
			/**
			 * 00_01_02为特征码
			 * 或者是 控制器的唯一标识
			 */
				Map<String,Object> oneRegisterEventTypeData = new HashMap<String, Object>();
					EventStructureMetaModel eventStructureMetaModel = new EventStructureMetaModel();
					eventStructureMetaModel.setControllerId("shortcutController01");
					eventStructureMetaModel.setRootControllerId("desktopController");
					eventStructureMetaModel.setResponseModeId("00_01_02");
				oneRegisterEventTypeData.put("eventstructuremetamodel", eventStructureMetaModel);
				
					Map<String,Object> oneDispacherEventTypeData = new HashMap<String, Object>();
						EventStructureMetaModel subEventStructureMetaModel = new EventStructureMetaModel();
						subEventStructureMetaModel.setControllerId("1_1_windowController_Organisation");
						subEventStructureMetaModel.setRootControllerId("1_1_windowController_Organisation");
					oneDispacherEventTypeData.put("eventstructuremetamodel", subEventStructureMetaModel);
					oneDispacherEventTypeData.put("count", 7);
				oneRegisterEventTypeData.put("dispachereventtype", "0007");
				
			RegisterEventTypeDatas.put("0003", oneRegisterEventTypeData);
			//codes1.add("0002");
		map2.put("registereventtypes", RegisterEventTypeDatas);
			Map<String,Object> dispacherEventTypeDatas = new HashMap<String, Object>();
			dispacherEventTypeDatas.put("0007", oneDispacherEventTypeData);
		map2.put("dispachereventtypes", dispacherEventTypeDatas);
		//map2.put("icon", "user");
		//map2.put("icon", "extanim32");
		map2.put("text", "Rpc   -----LoginView----AppEvents.DESKTOP_INIT_FOR_LOGGED_IN_USER");	
		GxtComponentMetaNodeModel node2=new GxtComponentMetaNodeModel(map2);
		return node2;
	}

	@Override
	public BaseDisplay getDisplay() {
		// TODO Auto-generated method stub
		return this.display;
	}

	
}
